#include "student.h"
#include<list>
using namespace std;

string Student::get_content()
{
	return manage_homework;
}

string Student::get_homework() {
	string s = "";
	for (int i = 0; i < arrange.size(); i++)
		s.append(arrange[i]->get_content()+" ");
	return s;
}

void Student::update_content()
{
	manage_homework = name + ": " + get_homework();
}

void Student::add(teacher* tea)
{
	arrange.push_back(tea);
}

void Student::del_homework(teacher* tea)
{
	int j = 0;
	for (; j < arrange.size(); j++) {
		if (arrange[j] == tea)
			break;
	}
	int n = arrange[j]->get_content().size();
	int m = manage_homework.find(arrange[j]->get_content());
	manage_homework.erase(m, n);
	auto i = remove(arrange.begin(), arrange.end(), tea);
	arrange.erase(i, arrange.end());
	cout << name + " delete the lesson of " << tea->get_name() << endl;
}

void Student::get_teacher()
{
	string s = "";
	for (int i = 0; i < arrange.size(); i++)
		s.append(arrange[i]->get_name() + " ");
	cout << name << " choose the lesson of " << s << endl;
}